import unittest
from alg import MajorityElementSolver
from gen import TestGenerator


class TestMajorityElement(unittest.TestCase):
    def setUp(self):
        self.solver = MajorityElementSolver()
        self.test_cases = TestGenerator.generate_test_cases()

    def test_majority_element(self):
        for nums, expected in self.test_cases:
            with self.subTest(nums=nums):
                result = self.solver.solve(nums)
                self.assertEqual(result, expected, f"Failed for nums={nums}")


if __name__ == '__main__':
    unittest.main()